Implement new PIF-based network model, and match movement of I/O-statistics.
authorEwan Mellor <ewan@xensource.com>
Thu, 26 Oct 2006 14:59:51 +0000 (15:59 +0100)
committerEwan Mellor <ewan@xensource.com>
Thu, 26 Oct 2006 14:59:51 +0000 (15:59 +0100)
Signed-off-by: Ewan Mellor <ewan@xensource.com>
tools/libxen/include/xen_host.h
tools/libxen/include/xen_network.h
tools/libxen/include/xen_pif.h [new file with mode: 0644]
tools/libxen/include/xen_pif_decl.h [new file with mode: 0644]
tools/libxen/include/xen_vbd.h
tools/libxen/include/xen_vif.h
tools/libxen/src/xen_host.c
tools/libxen/src/xen_network.c
tools/libxen/src/xen_pif.c [new file with mode: 0644]
tools/libxen/src/xen_vbd.c
tools/libxen/src/xen_vif.c

index 7b905b893b2df7a4b877479741fa2c9051958ce4..d8ed1e776c2e057de58b13e233a8645dfd00690e 100644 (file)
@@ -22,6 +22,7 @@
 #include "xen_common.h"
 #include "xen_host_cpu_decl.h"
 #include "xen_host_decl.h"
+#include "xen_pif_decl.h"
 #include "xen_string_string_map.h"
 #include "xen_vm_decl.h"
 
@@ -69,6 +70,7 @@ typedef struct xen_host_record
     char *name_description;
     xen_string_string_map *software_version;
     struct xen_vm_record_opt_set *resident_vms;
+    struct xen_pif_record_opt_set *pifs;
     struct xen_host_cpu_record_opt_set *host_cpus;
 } xen_host_record;
 
@@ -214,6 +216,13 @@ extern bool
 xen_host_get_resident_vms(xen_session *session, xen_vm *result, xen_host host);
 
 
+/**
+ * Get the PIFs field of the given host.
+ */
+extern bool
+xen_host_get_pifs(xen_session *session, xen_pif *result, xen_host host);
+
+
 /**
  * Get the host_CPUs field of the given host.
  */
index 6dc21b170fa67d3cd1c82b4859b3f6992df13107..d701033a50502c520d906fb1003b631aefe51273 100644 (file)
@@ -21,6 +21,7 @@
 
 #include "xen_common.h"
 #include "xen_network_decl.h"
+#include "xen_pif_decl.h"
 #include "xen_vif_decl.h"
 
 
@@ -66,8 +67,7 @@ typedef struct xen_network_record
     char *name_label;
     char *name_description;
     struct xen_vif_record_opt_set *vifs;
-    char *nic;
-    char *vlan;
+    struct xen_pif_record_opt_set *pifs;
     char *default_gateway;
     char *default_netmask;
 } xen_network_record;
@@ -208,17 +208,10 @@ xen_network_get_vifs(xen_session *session, xen_vif *result, xen_network network)
 
 
 /**
- * Get the NIC field of the given network.
+ * Get the PIFs field of the given network.
  */
 extern bool
-xen_network_get_nic(xen_session *session, char **result, xen_network network);
-
-
-/**
- * Get the VLAN field of the given network.
- */
-extern bool
-xen_network_get_vlan(xen_session *session, char **result, xen_network network);
+xen_network_get_pifs(xen_session *session, xen_pif *result, xen_network network);
 
 
 /**
@@ -249,20 +242,6 @@ extern bool
 xen_network_set_name_description(xen_session *session, xen_network xen_network, char *description);
 
 
-/**
- * Set the NIC field of the given network.
- */
-extern bool
-xen_network_set_nic(xen_session *session, xen_network xen_network, char *nic);
-
-
-/**
- * Set the VLAN field of the given network.
- */
-extern bool
-xen_network_set_vlan(xen_session *session, xen_network xen_network, char *vlan);
-
-
 /**
  * Set the default_gateway field of the given network.
  */
diff --git a/tools/libxen/include/xen_pif.h b/tools/libxen/include/xen_pif.h
new file mode 100644 (file)
index 0000000..57ead48
--- /dev/null
@@ -0,0 +1,283 @@
+/*
+ * Copyright (c) 2006, XenSource Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ */
+
+#ifndef XEN_PIF_H
+#define XEN_PIF_H
+
+#include "xen_common.h"
+#include "xen_host_decl.h"
+#include "xen_network_decl.h"
+#include "xen_pif_decl.h"
+
+
+/*
+ * The PIF class. 
+ *  
+ * A physical network interface (note separate VLANs are represented as
+ * several PIFs).
+ */
+
+
+/**
+ * Free the given xen_pif.  The given handle must have been allocated
+ * by this library.
+ */
+extern void
+xen_pif_free(xen_pif pif);
+
+
+typedef struct xen_pif_set
+{
+    size_t size;
+    xen_pif *contents[];
+} xen_pif_set;
+
+/**
+ * Allocate a xen_pif_set of the given size.
+ */
+extern xen_pif_set *
+xen_pif_set_alloc(size_t size);
+
+/**
+ * Free the given xen_pif_set.  The given set must have been allocated
+ * by this library.
+ */
+extern void
+xen_pif_set_free(xen_pif_set *set);
+
+
+typedef struct xen_pif_record
+{
+    xen_pif handle;
+    char *uuid;
+    char *name;
+    struct xen_network_record_opt *network;
+    struct xen_host_record_opt *host;
+    char *mac;
+    uint64_t mtu;
+    char *vlan;
+    double io_read_kbs;
+    double io_write_kbs;
+} xen_pif_record;
+
+/**
+ * Allocate a xen_pif_record.
+ */
+extern xen_pif_record *
+xen_pif_record_alloc(void);
+
+/**
+ * Free the given xen_pif_record, and all referenced values.  The given
+ * record must have been allocated by this library.
+ */
+extern void
+xen_pif_record_free(xen_pif_record *record);
+
+
+typedef struct xen_pif_record_opt
+{
+    bool is_record;
+    union
+    {
+        xen_pif handle;
+        xen_pif_record *record;
+    } u;
+} xen_pif_record_opt;
+
+/**
+ * Allocate a xen_pif_record_opt.
+ */
+extern xen_pif_record_opt *
+xen_pif_record_opt_alloc(void);
+
+/**
+ * Free the given xen_pif_record_opt, and all referenced values.  The
+ * given record_opt must have been allocated by this library.
+ */
+extern void
+xen_pif_record_opt_free(xen_pif_record_opt *record_opt);
+
+
+typedef struct xen_pif_record_set
+{
+    size_t size;
+    xen_pif_record *contents[];
+} xen_pif_record_set;
+
+/**
+ * Allocate a xen_pif_record_set of the given size.
+ */
+extern xen_pif_record_set *
+xen_pif_record_set_alloc(size_t size);
+
+/**
+ * Free the given xen_pif_record_set, and all referenced values.  The
+ * given set must have been allocated by this library.
+ */
+extern void
+xen_pif_record_set_free(xen_pif_record_set *set);
+
+
+
+typedef struct xen_pif_record_opt_set
+{
+    size_t size;
+    xen_pif_record_opt *contents[];
+} xen_pif_record_opt_set;
+
+/**
+ * Allocate a xen_pif_record_opt_set of the given size.
+ */
+extern xen_pif_record_opt_set *
+xen_pif_record_opt_set_alloc(size_t size);
+
+/**
+ * Free the given xen_pif_record_opt_set, and all referenced values. 
+ * The given set must have been allocated by this library.
+ */
+extern void
+xen_pif_record_opt_set_free(xen_pif_record_opt_set *set);
+
+
+/**
+ * Get the current state of the given PIF.  !!!
+ */
+extern bool
+xen_pif_get_record(xen_session *session, xen_pif_record **result, xen_pif pif);
+
+
+/**
+ * Get a reference to the object with the specified UUID.  !!!
+ */
+extern bool
+xen_pif_get_by_uuid(xen_session *session, xen_pif *result, char *uuid);
+
+
+/**
+ * Create a new PIF instance, and return its handle.
+ */
+extern bool
+xen_pif_create(xen_session *session, xen_pif *result, xen_pif_record *record);
+
+
+/**
+ * Get the uuid field of the given PIF.
+ */
+extern bool
+xen_pif_get_uuid(xen_session *session, char **result, xen_pif pif);
+
+
+/**
+ * Get the name field of the given PIF.
+ */
+extern bool
+xen_pif_get_name(xen_session *session, char **result, xen_pif pif);
+
+
+/**
+ * Get the network field of the given PIF.
+ */
+extern bool
+xen_pif_get_network(xen_session *session, xen_network *result, xen_pif pif);
+
+
+/**
+ * Get the host field of the given PIF.
+ */
+extern bool
+xen_pif_get_host(xen_session *session, xen_host *result, xen_pif pif);
+
+
+/**
+ * Get the MAC field of the given PIF.
+ */
+extern bool
+xen_pif_get_mac(xen_session *session, char **result, xen_pif pif);
+
+
+/**
+ * Get the MTU field of the given PIF.
+ */
+extern bool
+xen_pif_get_mtu(xen_session *session, uint64_t *result, xen_pif pif);
+
+
+/**
+ * Get the VLAN field of the given PIF.
+ */
+extern bool
+xen_pif_get_vlan(xen_session *session, char **result, xen_pif pif);
+
+
+/**
+ * Get the io/read_kbs field of the given PIF.
+ */
+extern bool
+xen_pif_get_io_read_kbs(xen_session *session, double *result, xen_pif pif);
+
+
+/**
+ * Get the io/write_kbs field of the given PIF.
+ */
+extern bool
+xen_pif_get_io_write_kbs(xen_session *session, double *result, xen_pif pif);
+
+
+/**
+ * Set the name field of the given PIF.
+ */
+extern bool
+xen_pif_set_name(xen_session *session, xen_pif xen_pif, char *name);
+
+
+/**
+ * Set the network field of the given PIF.
+ */
+extern bool
+xen_pif_set_network(xen_session *session, xen_pif xen_pif, xen_network network);
+
+
+/**
+ * Set the host field of the given PIF.
+ */
+extern bool
+xen_pif_set_host(xen_session *session, xen_pif xen_pif, xen_host host);
+
+
+/**
+ * Set the MAC field of the given PIF.
+ */
+extern bool
+xen_pif_set_mac(xen_session *session, xen_pif xen_pif, char *mac);
+
+
+/**
+ * Set the MTU field of the given PIF.
+ */
+extern bool
+xen_pif_set_mtu(xen_session *session, xen_pif xen_pif, uint64_t mtu);
+
+
+/**
+ * Set the VLAN field of the given PIF.
+ */
+extern bool
+xen_pif_set_vlan(xen_session *session, xen_pif xen_pif, char *vlan);
+
+
+#endif
diff --git a/tools/libxen/include/xen_pif_decl.h b/tools/libxen/include/xen_pif_decl.h
new file mode 100644 (file)
index 0000000..b326bea
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2006, XenSource Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ */
+
+#ifndef XEN_PIF_DECL_H
+#define XEN_PIF_DECL_H
+
+typedef void *xen_pif;
+
+struct xen_pif_set;
+struct xen_pif_record;
+struct xen_pif_record_set;
+struct xen_pif_record_opt;
+struct xen_pif_record_opt_set;
+
+#endif
index 0ef7dec15d1130a8e7ed5c899681d2c69f1a555d..48d4c32ea7526b488b6b65c8dad16869bff3e04f 100644 (file)
@@ -71,8 +71,8 @@ typedef struct xen_vbd_record
     char *device;
     enum xen_vbd_mode mode;
     enum xen_driver_type driver;
-    double io_bandwidth_incoming_kbs;
-    double io_bandwidth_outgoing_kbs;
+    double io_read_kbs;
+    double io_write_kbs;
 } xen_vbd_record;
 
 /**
@@ -218,17 +218,17 @@ xen_vbd_get_driver(xen_session *session, enum xen_driver_type *result, xen_vbd v
 
 
 /**
- * Get the IO_bandwidth/incoming_kbs field of the given VBD.
+ * Get the io/read_kbs field of the given VBD.
  */
 extern bool
-xen_vbd_get_io_bandwidth_incoming_kbs(xen_session *session, double *result, xen_vbd vbd);
+xen_vbd_get_io_read_kbs(xen_session *session, double *result, xen_vbd vbd);
 
 
 /**
- * Get the IO_bandwidth/outgoing_kbs field of the given VBD.
+ * Get the io/write_kbs field of the given VBD.
  */
 extern bool
-xen_vbd_get_io_bandwidth_outgoing_kbs(xen_session *session, double *result, xen_vbd vbd);
+xen_vbd_get_io_write_kbs(xen_session *session, double *result, xen_vbd vbd);
 
 
 /**
@@ -266,4 +266,12 @@ extern bool
 xen_vbd_set_driver(xen_session *session, xen_vbd xen_vbd, enum xen_driver_type driver);
 
 
+/**
+ * Change the media in the device for CDROM-like devices only. For
+ * other devices, detach the VBD and attach a new one
+ */
+extern bool
+xen_vbd_media_change(xen_session *session, xen_vbd vbd, xen_vdi vdi);
+
+
 #endif
index 23c6fc997a6c8a4f3609b2decf27c7a9cc18b5b7..bbb91b34abf1c09046d726867dcf33ae9629b4ff 100644 (file)
@@ -72,10 +72,8 @@ typedef struct xen_vif_record
     struct xen_vm_record_opt *vm;
     char *mac;
     uint64_t mtu;
-    double network_read_kbs;
-    double network_write_kbs;
-    double io_bandwidth_incoming_kbs;
-    double io_bandwidth_outgoing_kbs;
+    double io_read_kbs;
+    double io_write_kbs;
 } xen_vif_record;
 
 /**
@@ -235,31 +233,17 @@ xen_vif_get_mtu(xen_session *session, uint64_t *result, xen_vif vif);
 
 
 /**
- * Get the network_read_kbs field of the given VIF.
+ * Get the io/read_kbs field of the given VIF.
  */
 extern bool
-xen_vif_get_network_read_kbs(xen_session *session, double *result, xen_vif vif);
+xen_vif_get_io_read_kbs(xen_session *session, double *result, xen_vif vif);
 
 
 /**
- * Get the network_write_kbs field of the given VIF.
+ * Get the io/write_kbs field of the given VIF.
  */
 extern bool
-xen_vif_get_network_write_kbs(xen_session *session, double *result, xen_vif vif);
-
-
-/**
- * Get the IO_bandwidth/incoming_kbs field of the given VIF.
- */
-extern bool
-xen_vif_get_io_bandwidth_incoming_kbs(xen_session *session, double *result, xen_vif vif);
-
-
-/**
- * Get the IO_bandwidth/outgoing_kbs field of the given VIF.
- */
-extern bool
-xen_vif_get_io_bandwidth_outgoing_kbs(xen_session *session, double *result, xen_vif vif);
+xen_vif_get_io_write_kbs(xen_session *session, double *result, xen_vif vif);
 
 
 /**
index 5bb947bac00c02b2156d9f0f1941b1815d45dbe8..0eb26e8cfedc538f26aecf098705baa88a3c0901 100644 (file)
@@ -24,6 +24,7 @@
 #include "xen_host.h"
 #include "xen_host_cpu.h"
 #include "xen_internal.h"
+#include "xen_pif.h"
 #include "xen_string_string_map.h"
 #include "xen_vm.h"
 
@@ -54,6 +55,9 @@ static const struct_member xen_host_record_struct_members[] =
         { .key = "resident_vms",
           .type = &abstract_type_ref_set,
           .offset = offsetof(xen_host_record, resident_vms) },
+        { .key = "pifs",
+          .type = &abstract_type_ref_set,
+          .offset = offsetof(xen_host_record, pifs) },
         { .key = "host_cpus",
           .type = &abstract_type_ref_set,
           .offset = offsetof(xen_host_record, host_cpus) }
@@ -78,6 +82,7 @@ xen_host_record_free(xen_host_record *record)
     free(record->name_description);
     xen_string_string_map_free(record->software_version);
     xen_vm_record_opt_set_free(record->resident_vms);
+    xen_pif_record_opt_set_free(record->pifs);
     xen_host_cpu_record_opt_set_free(record->host_cpus);
     free(record);
 }
@@ -225,6 +230,23 @@ xen_host_get_resident_vms(xen_session *session, xen_vm *result, xen_host host)
 }
 
 
+bool
+xen_host_get_pifs(xen_session *session, xen_pif *result, xen_host host)
+{
+    abstract_value param_values[] =
+        {
+            { .type = &abstract_type_string,
+              .u.string_val = host }
+        };
+
+    abstract_type result_type = abstract_type_string_set;
+
+    *result = NULL;
+    XEN_CALL_("host.get_pifs");
+    return session->ok;
+}
+
+
 bool
 xen_host_get_host_cpus(xen_session *session, xen_host_cpu *result, xen_host host)
 {
index 05eecd6445eb312970299e620298703c901f0e43..4b336a10b29db628a0155b7dfe361d1738dda398 100644 (file)
@@ -23,6 +23,7 @@
 #include "xen_common.h"
 #include "xen_internal.h"
 #include "xen_network.h"
+#include "xen_pif.h"
 #include "xen_vif.h"
 
 
@@ -49,12 +50,9 @@ static const struct_member xen_network_record_struct_members[] =
         { .key = "vifs",
           .type = &abstract_type_ref_set,
           .offset = offsetof(xen_network_record, vifs) },
-        { .key = "nic",
-          .type = &abstract_type_string,
-          .offset = offsetof(xen_network_record, nic) },
-        { .key = "vlan",
-          .type = &abstract_type_string,
-          .offset = offsetof(xen_network_record, vlan) },
+        { .key = "pifs",
+          .type = &abstract_type_ref_set,
+          .offset = offsetof(xen_network_record, pifs) },
         { .key = "default_gateway",
           .type = &abstract_type_string,
           .offset = offsetof(xen_network_record, default_gateway) },
@@ -81,8 +79,7 @@ xen_network_record_free(xen_network_record *record)
     free(record->name_label);
     free(record->name_description);
     xen_vif_record_opt_set_free(record->vifs);
-    free(record->nic);
-    free(record->vlan);
+    xen_pif_record_opt_set_free(record->pifs);
     free(record->default_gateway);
     free(record->default_netmask);
     free(record);
@@ -215,7 +212,7 @@ xen_network_get_vifs(xen_session *session, xen_vif *result, xen_network network)
 
 
 bool
-xen_network_get_nic(xen_session *session, char **result, xen_network network)
+xen_network_get_pifs(xen_session *session, xen_pif *result, xen_network network)
 {
     abstract_value param_values[] =
         {
@@ -223,27 +220,10 @@ xen_network_get_nic(xen_session *session, char **result, xen_network network)
               .u.string_val = network }
         };
 
-    abstract_type result_type = abstract_type_string;
-
-    *result = NULL;
-    XEN_CALL_("network.get_nic");
-    return session->ok;
-}
-
-
-bool
-xen_network_get_vlan(xen_session *session, char **result, xen_network network)
-{
-    abstract_value param_values[] =
-        {
-            { .type = &abstract_type_string,
-              .u.string_val = network }
-        };
-
-    abstract_type result_type = abstract_type_string;
+    abstract_type result_type = abstract_type_string_set;
 
     *result = NULL;
-    XEN_CALL_("network.get_vlan");
+    XEN_CALL_("network.get_pifs");
     return session->ok;
 }
 
@@ -314,38 +294,6 @@ xen_network_set_name_description(xen_session *session, xen_network xen_network,
 }
 
 
-bool
-xen_network_set_nic(xen_session *session, xen_network xen_network, char *nic)
-{
-    abstract_value param_values[] =
-        {
-            { .type = &abstract_type_string,
-              .u.string_val = xen_network },
-            { .type = &abstract_type_string,
-              .u.string_val = nic }
-        };
-
-    xen_call_(session, "network.set_nic", param_values, 2, NULL, NULL);
-    return session->ok;
-}
-
-
-bool
-xen_network_set_vlan(xen_session *session, xen_network xen_network, char *vlan)
-{
-    abstract_value param_values[] =
-        {
-            { .type = &abstract_type_string,
-              .u.string_val = xen_network },
-            { .type = &abstract_type_string,
-              .u.string_val = vlan }
-        };
-
-    xen_call_(session, "network.set_vlan", param_values, 2, NULL, NULL);
-    return session->ok;
-}
-
-
 bool
 xen_network_set_default_gateway(xen_session *session, xen_network xen_network, char *default_gateway)
 {
diff --git a/tools/libxen/src/xen_pif.c b/tools/libxen/src/xen_pif.c
new file mode 100644 (file)
index 0000000..165b49e
--- /dev/null
@@ -0,0 +1,385 @@
+/*
+ * Copyright (c) 2006, XenSource Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
+ */
+
+
+#include <stddef.h>
+#include <stdlib.h>
+
+#include "xen_common.h"
+#include "xen_host.h"
+#include "xen_internal.h"
+#include "xen_network.h"
+#include "xen_pif.h"
+
+
+XEN_FREE(xen_pif)
+XEN_SET_ALLOC_FREE(xen_pif)
+XEN_ALLOC(xen_pif_record)
+XEN_SET_ALLOC_FREE(xen_pif_record)
+XEN_ALLOC(xen_pif_record_opt)
+XEN_RECORD_OPT_FREE(xen_pif)
+XEN_SET_ALLOC_FREE(xen_pif_record_opt)
+
+
+static const struct_member xen_pif_record_struct_members[] =
+    {
+        { .key = "uuid",
+          .type = &abstract_type_string,
+          .offset = offsetof(xen_pif_record, uuid) },
+        { .key = "name",
+          .type = &abstract_type_string,
+          .offset = offsetof(xen_pif_record, name) },
+        { .key = "network",
+          .type = &abstract_type_ref,
+          .offset = offsetof(xen_pif_record, network) },
+        { .key = "host",
+          .type = &abstract_type_ref,
+          .offset = offsetof(xen_pif_record, host) },
+        { .key = "mac",
+          .type = &abstract_type_string,
+          .offset = offsetof(xen_pif_record, mac) },
+        { .key = "mtu",
+          .type = &abstract_type_int,
+          .offset = offsetof(xen_pif_record, mtu) },
+        { .key = "vlan",
+          .type = &abstract_type_string,
+          .offset = offsetof(xen_pif_record, vlan) },
+        { .key = "io_read_kbs",
+          .type = &abstract_type_float,
+          .offset = offsetof(xen_pif_record, io_read_kbs) },
+        { .key = "io_write_kbs",
+          .type = &abstract_type_float,
+          .offset = offsetof(xen_pif_record, io_write_kbs) }
+    };
+
+const abstract_type xen_pif_record_abstract_type_ =
+    {
+       .typename = STRUCT,
+       .struct_size = sizeof(xen_pif_record),
+       .member_count =
+           sizeof(xen_pif_record_struct_members) / sizeof(struct_member),
+       .members = xen_pif_record_struct_members
+    };
+
+
+void
+xen_pif_record_free(xen_pif_record *record)
+{
+    free(record->handle);
+    free(record->uuid);
+    free(record->name);
+    xen_network_record_opt_free(record->network);
+    xen_host_record_opt_free(record->host);
+    free(record->mac);
+    free(record->vlan);
+    free(record);
+}
+
+
+bool
+xen_pif_get_record(xen_session *session, xen_pif_record **result, xen_pif pif)
+{
+    abstract_value param_values[] =
+        {
+            { .type = &abstract_type_string,
+              .u.string_val = pif }
+        };
+
+    abstract_type result_type = xen_pif_record_abstract_type_;
+
+    *result = NULL;
+    XEN_CALL_("PIF.get_record");
+
+    if (session->ok)
+    {
+       (*result)->handle = xen_strdup_((*result)->uuid);
+    }
+
+    return session->ok;
+}
+
+
+bool
+xen_pif_get_by_uuid(xen_session *session, xen_pif *result, char *uuid)
+{
+    abstract_value param_values[] =
+        {
+            { .type = &abstract_type_string,
+              .u.string_val = uuid }
+        };
+
+    abstract_type result_type = abstract_type_string;
+
+    *result = NULL;
+    XEN_CALL_("PIF.get_by_uuid");
+    return session->ok;
+}
+
+
+bool
+xen_pif_create(xen_session *session, xen_pif *result, xen_pif_record *record)
+{
+    abstract_value param_values[] =
+        {
+            { .type = &xen_pif_record_abstract_type_,
+              .u.struct_val = record }
+        };
+
+    abstract_type result_type = abstract_type_string;
+
+    *result = NULL;
+    XEN_CALL_("PIF.create");
+    return session->ok;
+}
+
+
+bool
+xen_pif_get_name(xen_session *session, char **result, xen_pif pif)
+{
+    abstract_value param_values[] =
+        {
+            { .type = &abstract_type_string,
+              .u.string_val = pif }
+        };
+
+    abstract_type result_type = abstract_type_string;
+
+    *result = NULL;
+    XEN_CALL_("PIF.get_name");
+    return session->ok;
+}
+
+
+bool
+xen_pif_get_network(xen_session *session, xen_network *result, xen_pif pif)
+{
+    abstract_value param_values[] =
+        {
+            { .type = &abstract_type_string,
+              .u.string_val = pif }
+        };
+
+    abstract_type result_type = abstract_type_string;
+
+    *result = NULL;
+    XEN_CALL_("PIF.get_network");
+    return session->ok;
+}
+
+
+bool
+xen_pif_get_host(xen_session *session, xen_host *result, xen_pif pif)
+{
+    abstract_value param_values[] =
+        {
+            { .type = &abstract_type_string,
+              .u.string_val = pif }
+        };
+
+    abstract_type result_type = abstract_type_string;
+
+    *result = NULL;
+    XEN_CALL_("PIF.get_host");
+    return session->ok;
+}
+
+
+bool
+xen_pif_get_mac(xen_session *session, char **result, xen_pif pif)
+{
+    abstract_value param_values[] =
+        {
+            { .type = &abstract_type_string,
+              .u.string_val = pif }
+        };
+
+    abstract_type result_type = abstract_type_string;
+
+    *result = NULL;
+    XEN_CALL_("PIF.get_mac");
+    return session->ok;
+}
+
+
+bool
+xen_pif_get_mtu(xen_session *session, uint64_t *result, xen_pif pif)
+{
+    abstract_value param_values[] =
+        {
+            { .type = &abstract_type_string,
+              .u.string_val = pif }
+        };
+
+    abstract_type result_type = abstract_type_int;
+
+    XEN_CALL_("PIF.get_mtu");
+    return session->ok;
+}
+
+
+bool
+xen_pif_get_vlan(xen_session *session, char **result, xen_pif pif)
+{
+    abstract_value param_values[] =
+        {
+            { .type = &abstract_type_string,
+              .u.string_val = pif }
+        };
+
+    abstract_type result_type = abstract_type_string;
+
+    *result = NULL;
+    XEN_CALL_("PIF.get_vlan");
+    return session->ok;
+}
+
+
+bool
+xen_pif_get_io_read_kbs(xen_session *session, double *result, xen_pif pif)
+{
+    abstract_value param_values[] =
+        {
+            { .type = &abstract_type_string,
+              .u.string_val = pif }
+        };
+
+    abstract_type result_type = abstract_type_float;
+
+    XEN_CALL_("PIF.get_io_read_kbs");
+    return session->ok;
+}
+
+
+bool
+xen_pif_get_io_write_kbs(xen_session *session, double *result, xen_pif pif)
+{
+    abstract_value param_values[] =
+        {
+            { .type = &abstract_type_string,
+              .u.string_val = pif }
+        };
+
+    abstract_type result_type = abstract_type_float;
+
+    XEN_CALL_("PIF.get_io_write_kbs");
+    return session->ok;
+}
+
+
+bool
+xen_pif_set_name(xen_session *session, xen_pif xen_pif, char *name)
+{
+    abstract_value param_values[] =
+        {
+            { .type = &abstract_type_string,
+              .u.string_val = xen_pif },
+            { .type = &abstract_type_string,
+              .u.string_val = name }
+        };
+
+    xen_call_(session, "PIF.set_name", param_values, 2, NULL, NULL);
+    return session->ok;
+}
+
+
+bool
+xen_pif_set_network(xen_session *session, xen_pif xen_pif, xen_network network)
+{
+    abstract_value param_values[] =
+        {
+            { .type = &abstract_type_string,
+              .u.string_val = xen_pif },
+            { .type = &abstract_type_string,
+              .u.string_val = network }
+        };
+
+    xen_call_(session, "PIF.set_network", param_values, 2, NULL, NULL);
+    return session->ok;
+}
+
+
+bool
+xen_pif_set_host(xen_session *session, xen_pif xen_pif, xen_host host)
+{
+    abstract_value param_values[] =
+        {
+            { .type = &abstract_type_string,
+              .u.string_val = xen_pif },
+            { .type = &abstract_type_string,
+              .u.string_val = host }
+        };
+
+    xen_call_(session, "PIF.set_host", param_values, 2, NULL, NULL);
+    return session->ok;
+}
+
+
+bool
+xen_pif_set_mac(xen_session *session, xen_pif xen_pif, char *mac)
+{
+    abstract_value param_values[] =
+        {
+            { .type = &abstract_type_string,
+              .u.string_val = xen_pif },
+            { .type = &abstract_type_string,
+              .u.string_val = mac }
+        };
+
+    xen_call_(session, "PIF.set_mac", param_values, 2, NULL, NULL);
+    return session->ok;
+}
+
+
+bool
+xen_pif_set_mtu(xen_session *session, xen_pif xen_pif, uint64_t mtu)
+{
+    abstract_value param_values[] =
+        {
+            { .type = &abstract_type_string,
+              .u.string_val = xen_pif },
+            { .type = &abstract_type_int,
+              .u.int_val = mtu }
+        };
+
+    xen_call_(session, "PIF.set_mtu", param_values, 2, NULL, NULL);
+    return session->ok;
+}
+
+
+bool
+xen_pif_set_vlan(xen_session *session, xen_pif xen_pif, char *vlan)
+{
+    abstract_value param_values[] =
+        {
+            { .type = &abstract_type_string,
+              .u.string_val = xen_pif },
+            { .type = &abstract_type_string,
+              .u.string_val = vlan }
+        };
+
+    xen_call_(session, "PIF.set_vlan", param_values, 2, NULL, NULL);
+    return session->ok;
+}
+
+
+bool
+xen_pif_get_uuid(xen_session *session, char **result, xen_pif pif)
+{
+    *result = session->ok ? xen_strdup_((char *)pif) : NULL;
+    return session->ok;
+}
index 7aa2ea924515b55e7f312be78ddaaf9bb217474f..f093bbffa932711b5959e9200a3d5efded06b2e8 100644 (file)
@@ -58,12 +58,12 @@ static const struct_member xen_vbd_record_struct_members[] =
         { .key = "driver",
           .type = &xen_driver_type_abstract_type_,
           .offset = offsetof(xen_vbd_record, driver) },
-        { .key = "io_bandwidth_incoming_kbs",
+        { .key = "io_read_kbs",
           .type = &abstract_type_float,
-          .offset = offsetof(xen_vbd_record, io_bandwidth_incoming_kbs) },
-        { .key = "io_bandwidth_outgoing_kbs",
+          .offset = offsetof(xen_vbd_record, io_read_kbs) },
+        { .key = "io_write_kbs",
           .type = &abstract_type_float,
-          .offset = offsetof(xen_vbd_record, io_bandwidth_outgoing_kbs) }
+          .offset = offsetof(xen_vbd_record, io_write_kbs) }
     };
 
 const abstract_type xen_vbd_record_abstract_type_ =
@@ -231,7 +231,7 @@ xen_vbd_get_driver(xen_session *session, enum xen_driver_type *result, xen_vbd v
 
 
 bool
-xen_vbd_get_io_bandwidth_incoming_kbs(xen_session *session, double *result, xen_vbd vbd)
+xen_vbd_get_io_read_kbs(xen_session *session, double *result, xen_vbd vbd)
 {
     abstract_value param_values[] =
         {
@@ -241,13 +241,13 @@ xen_vbd_get_io_bandwidth_incoming_kbs(xen_session *session, double *result, xen_
 
     abstract_type result_type = abstract_type_float;
 
-    XEN_CALL_("VBD.get_io_bandwidth_incoming_kbs");
+    XEN_CALL_("VBD.get_io_read_kbs");
     return session->ok;
 }
 
 
 bool
-xen_vbd_get_io_bandwidth_outgoing_kbs(xen_session *session, double *result, xen_vbd vbd)
+xen_vbd_get_io_write_kbs(xen_session *session, double *result, xen_vbd vbd)
 {
     abstract_value param_values[] =
         {
@@ -257,7 +257,7 @@ xen_vbd_get_io_bandwidth_outgoing_kbs(xen_session *session, double *result, xen_
 
     abstract_type result_type = abstract_type_float;
 
-    XEN_CALL_("VBD.get_io_bandwidth_outgoing_kbs");
+    XEN_CALL_("VBD.get_io_write_kbs");
     return session->ok;
 }
 
@@ -342,6 +342,22 @@ xen_vbd_set_driver(xen_session *session, xen_vbd xen_vbd, enum xen_driver_type d
 }
 
 
+bool
+xen_vbd_media_change(xen_session *session, xen_vbd vbd, xen_vdi vdi)
+{
+    abstract_value param_values[] =
+        {
+            { .type = &abstract_type_string,
+              .u.string_val = vbd },
+            { .type = &abstract_type_string,
+              .u.string_val = vdi }
+        };
+
+    xen_call_(session, "VBD.media_change", param_values, 2, NULL, NULL);
+    return session->ok;
+}
+
+
 bool
 xen_vbd_get_uuid(xen_session *session, char **result, xen_vbd vbd)
 {
index 7554fb154a85deebb187fead94f6195d15f73379..5d8df97e5db6484a927ddf5097949b1125df7e84 100644 (file)
@@ -63,18 +63,12 @@ static const struct_member xen_vif_record_struct_members[] =
         { .key = "mtu",
           .type = &abstract_type_int,
           .offset = offsetof(xen_vif_record, mtu) },
-        { .key = "network_read_kbs",
+        { .key = "io_read_kbs",
           .type = &abstract_type_float,
-          .offset = offsetof(xen_vif_record, network_read_kbs) },
-        { .key = "network_write_kbs",
+          .offset = offsetof(xen_vif_record, io_read_kbs) },
+        { .key = "io_write_kbs",
           .type = &abstract_type_float,
-          .offset = offsetof(xen_vif_record, network_write_kbs) },
-        { .key = "io_bandwidth_incoming_kbs",
-          .type = &abstract_type_float,
-          .offset = offsetof(xen_vif_record, io_bandwidth_incoming_kbs) },
-        { .key = "io_bandwidth_outgoing_kbs",
-          .type = &abstract_type_float,
-          .offset = offsetof(xen_vif_record, io_bandwidth_outgoing_kbs) }
+          .offset = offsetof(xen_vif_record, io_write_kbs) }
     };
 
 const abstract_type xen_vif_record_abstract_type_ =
@@ -277,39 +271,7 @@ xen_vif_get_mtu(xen_session *session, uint64_t *result, xen_vif vif)
 
 
 bool
-xen_vif_get_network_read_kbs(xen_session *session, double *result, xen_vif vif)
-{
-    abstract_value param_values[] =
-        {
-            { .type = &abstract_type_string,
-              .u.string_val = vif }
-        };
-
-    abstract_type result_type = abstract_type_float;
-
-    XEN_CALL_("VIF.get_network_read_kbs");
-    return session->ok;
-}
-
-
-bool
-xen_vif_get_network_write_kbs(xen_session *session, double *result, xen_vif vif)
-{
-    abstract_value param_values[] =
-        {
-            { .type = &abstract_type_string,
-              .u.string_val = vif }
-        };
-
-    abstract_type result_type = abstract_type_float;
-
-    XEN_CALL_("VIF.get_network_write_kbs");
-    return session->ok;
-}
-
-
-bool
-xen_vif_get_io_bandwidth_incoming_kbs(xen_session *session, double *result, xen_vif vif)
+xen_vif_get_io_read_kbs(xen_session *session, double *result, xen_vif vif)
 {
     abstract_value param_values[] =
         {
@@ -319,13 +281,13 @@ xen_vif_get_io_bandwidth_incoming_kbs(xen_session *session, double *result, xen_
 
     abstract_type result_type = abstract_type_float;
 
-    XEN_CALL_("VIF.get_io_bandwidth_incoming_kbs");
+    XEN_CALL_("VIF.get_io_read_kbs");
     return session->ok;
 }
 
 
 bool
-xen_vif_get_io_bandwidth_outgoing_kbs(xen_session *session, double *result, xen_vif vif)
+xen_vif_get_io_write_kbs(xen_session *session, double *result, xen_vif vif)
 {
     abstract_value param_values[] =
         {
@@ -335,7 +297,7 @@ xen_vif_get_io_bandwidth_outgoing_kbs(xen_session *session, double *result, xen_
 
     abstract_type result_type = abstract_type_float;
 
-    XEN_CALL_("VIF.get_io_bandwidth_outgoing_kbs");
+    XEN_CALL_("VIF.get_io_write_kbs");
     return session->ok;
 }